package com.iflytek.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.iflytek.bean.Admin;
import com.iflytek.bean.Warehouse;
import com.iflytek.service.AdminService;
import com.iflytek.service.WarehouseService;
import com.iflytek.vo.layuiPage;

@RestController
@RequestMapping("/warehouse")
public class warehouseController {
	@Autowired
	private WarehouseService warehouseService;
	
	//展示
	@RequiresPermissions("warehouse:show")
	@GetMapping("/show")
	public Object goodsShow() {

		List<Warehouse> Page = warehouseService.selectByExample(null);
		
		layuiPage result = new layuiPage();
		result.setCode(0);
		result.setMsg("");
		result.setData(Page);
		return result;
	}
	
	//新增
	@RequiresPermissions("warehouse:add")
	@PostMapping("/add")
	public Object goodsAdd(Warehouse warehouse) {
		warehouseService.insertSelective(warehouse);
		layuiPage page = new layuiPage();
		page.setCode(0);
		page.setMsg("");
		page.setData(warehouse);
		return page;
		
	}
	
	//删除
	@RequiresPermissions("warehouse:del")
	@GetMapping("/del")
	public Object goodsDelete(Integer warehouseId) {
		warehouseService.deleteByPrimaryKey(warehouseId);
		layuiPage page = new layuiPage();
		page.setCode(0);
		page.setMsg("");
		return page;
	}
	
	
	//更新
	@PostMapping("/edit")
	public Object goodsEdit(Warehouse warehouse) {
		warehouseService.updateByPrimaryKeySelective(warehouse);
		
		layuiPage page = new layuiPage();
		page.setCode(0);
		page.setMsg("");
		page.setData(warehouse);
		return page;
	}
	
	//更新
		@GetMapping("/statusEdit")
		public Object statusEdit(Warehouse warehouse) {
			warehouseService.updateStatus(warehouse);
			
			layuiPage page = new layuiPage();
			page.setCode(0);
			page.setMsg("");
			page.setData(warehouse);
			return page;
		}
	
	
	
}
